package hlhj.fhp.supreme.activitys

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebViewClient
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response
import com.qiniu.android.utils.Json
import hlhj.fhp.supreme.BaseAty
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.javabean.PhoneBean
import hlhj.fhp.supreme.network.Urls
import hlhj.fhp.supreme.utils.JsonCallBack
import kotlinx.android.synthetic.main.activity_rule_aty.*

class RuleAty : BaseAty() {
    override fun getContentId(): Int {
        return R.layout.activity_rule_aty
    }

    override fun initView() {
        webView.settings.javaScriptEnabled=true
        webView.webViewClient=object : WebViewClient(){}
        webView.webChromeClient=object : WebChromeClient(){}
        OkGo.post<PhoneBean>(Urls.BaseUrl+Urls.PHONE)
                .params("type","agreement")
                .execute(object :JsonCallBack<PhoneBean>(this@RuleAty){
                    override fun onSuccess(response: Response<PhoneBean>?) {
                        val bean = response?.body()
                        if (bean?.code==1){
                            webView.loadDataWithBaseURL(null,bean?.data.agreement,"text/html", "utf-8", null)
                        }
                    }
                })

        btExit.setOnClickListener {
            finish()
        }
    }
}
